home *** CD-ROM | disk | FTP | other *** search
-
- {a quick little demo program to show the use of SDImage}
- {written by Michael Day 14 February 1989}
- {released to the public domain}
- {for best performance the IMG files should be directed to a RAM disk}
-
- program randbox;
-
- uses crt,graph,sdimage;
-
- var
- gr,gd:integer;
- ch : char;
- IT,screennum:integer;
- x1,y1,x2,y2:integer;
- StyleIt : integer;
- im:pointer;
-
- function fstr(i:integer):string;
- var s:string;
- begin
- str(i,s);
- fstr := s;
- end;
-
- procedure bomb(I:integer); {rats! show what went wrong}
- begin
- setfillstyle(solidfill,black);
- bar(0,0,100,10);
- setcolor(green);
- moveto(0,0);
- outtext('OOPS!:'+fstr(i)+':'+fstr(ImageError));
- Halt;
- end;
-
-
- {--------------------------------------------}
- {here is where it all begins}
-
- begin
- gr := 0;
- gd := 0;
- initgraph(gr,gd,'');
- setfillstyle(xhatchfill,white); {now clear the dispay}
- bar(0,0,GetMaxX,GetMaxY);
- setColor(white);
-
- { if you want to change the IMG path (such as to a ram disk) do it here}
- { if not(SetImagePath('F:\SDI')) then bomb(6); }
-
- {this allows you to change the buffer size}
- {if you want to see how it affects things}
- { if not AllocImageBuf(1,1000) then Bomb(3); }
-
- screennum := 0;
- repeat
- setfillstyle(solidfill,black); {now clear the dispay}
- bar(0,GetMaxY-10,GetMaxX,GetMaxY);
- setColor(white);
- outtextxy(2,GetMaxY-8,'Screen: '+fstr(screennum));
- inc(screennum);
-
- for IT := 0 to 7 do {create the images}
- begin
-
-
- x1 := random(GetmaxX shr 1); {defines the image area we will be using}
- y1 := random(GetmaxY shr 1);
- x2 := x1+random((GetmaxX shr 1)-80)+80;
- y2 := y1+random((GetmaxY shr 1)-40)+40;
-
- StyleIt := IT or $10;
- if not saveImage(IT,1, x1,y1,x2,y2, StyleIT) then bomb(1);
-
- {to see the difference between a compressed and non-compressed file}
- {enable the following statements and examine the resulting IMG files}
- {after a couple runs.}
-
- {
- StyleIt := IT;
- if not saveImage(IT+20,1, x1,y1,x2,y2, StyleIT) then bomb(1);
-
- StyleIt := IT or $10;
- if not saveImage(IT+30,1, x1,y1,x2,y2, StyleIT) then bomb(1);
- }
- setfillstyle(random(11)+1,random(14));
- setcolor(random(14));
-
- bar(x1,y1,x2,y2);
- rectangle(x1,y1,x2,y2);
- setColor(white);
- outtextxy(x1+2,y1+2,fstr(it));
- outtextxy(x1+2,y1+10,fstr(x1)+' '+fstr(y1));
- outtextxy(x1+2,y1+18,fstr(x2)+' '+fstr(y2));
- end;
-
- for IT := 7 downto 0 do {create the images}
- begin
- if not displayImage(IT,1, false) then bomb(2);
- end;
-
- setColor(white);
- ch := #255;
- if keypressed then ch := readkey; {stop when they tell us to}
- until ch < #32;
-
- end.